package com.cvte.vdtlibrary.bluetooth;

import android.os.Parcel;
import android.os.Parcelable;

import javax.crypto.EncryptedPrivateKeyInfo;

/**
 * Created by wuguitong on 2018/11/19.
 */
public class EntityBluetoothDevice implements Parcelable{
    private String name;
    private String mac;
    private EnumBtDeviceStatus status;

    public EntityBluetoothDevice(String mac, String name) {
        this.mac = mac;
        this.name = name;
        this.status = EnumBtDeviceStatus.DEV_NOT_PAIR;
    }

    public EntityBluetoothDevice(String mac, String name,EnumBtDeviceStatus status) {
        this.mac = mac;
        this.name = name;
        this.status = status;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMAC() {
        return mac;
    }

    public void setMAC(String MAC) {
        this.mac = MAC;
    }

    public EnumBtDeviceStatus getStatus() {
        return status;
    }

    public void setStatus(EnumBtDeviceStatus status) {
        this.status = status;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(mac);
        dest.writeString(name);
        dest.writeParcelable(status,flags);
    }
    public static final Creator<EntityBluetoothDevice>  CREATOR = new Creator<EntityBluetoothDevice>(){
        @Override
        public EntityBluetoothDevice createFromParcel(Parcel source) {
            return new EntityBluetoothDevice(source);
        }

        @Override
        public EntityBluetoothDevice[] newArray(int size) {
            return new EntityBluetoothDevice[size];
        }
    };

    public EntityBluetoothDevice(Parcel in) {
        this.mac = in.readString();
        this.name = in.readString();
        this.status = in.readParcelable(EnumBtDeviceStatus.class.getClassLoader());
    }

    @Override
    public boolean equals(Object obj) {
        if(this == obj){
            return true;
        }
        if(obj instanceof EntityBluetoothDevice){
            if(this.getMAC().equals(((EntityBluetoothDevice) obj).getMAC())){
                return true;
            }else{
                return false;
            }
        }else {
            return false;
        }
    }
}
